﻿using MvvmFx.Common.ViewModels;
using MvvmFx.Common.ViewModels.Behaviors.ChangeTracking;

namespace MvvmFx.Samples.HowTos.ChangeTracking.ViewModels
{
    public class AddressViewModel : ViewModelBase, IChangeTrackable
    {
        #region Fields

        private readonly ChangeService _changeService;
        private string _houseNameNumber;
        private string _streetName;
        private string _cityName;
        private string _country;
        private string _postCode;

        #endregion

        #region Constructor

        public AddressViewModel()
        {
            _changeService = new ChangeService(this);
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the value of the <see cref=”HouseNameNumber”/> property.
        /// </summary>
        public string HouseNameNumber
        {
            get { return _houseNameNumber; }
            set
            {
                if (_houseNameNumber != value)
                {
                    _houseNameNumber = value;
                    OnPropertyChanged("HouseNameNumber");
                }
            }
        }

        /// <summary>
        /// Gets or sets the value of the <see cref=”StreetName”/> property.
        /// </summary>
        public string StreetName
        {
            get { return _streetName; }
            set
            {
                if (_streetName != value)
                {
                    _streetName = value;
                    OnPropertyChanged("StreetName");
                }
            }
        }

        /// <summary>
        /// Gets or sets the value of the <see cref=”CityName”/> property.
        /// </summary>
        public string CityName
        {
            get { return _cityName; }
            set
            {
                if (_cityName != value)
                {
                    _cityName = value;
                    OnPropertyChanged("CityName");
                }
            }
        }

        /// <summary>
        /// Gets or sets the value of the <see cref=”Country”/> property.
        /// </summary>
        public string Country
        {
            get { return _country; }
            set
            {
                if (_country != value)
                {
                    _country = value;
                    OnPropertyChanged("Country");
                }
            }
        }

        /// <summary>
        /// Gets or sets the value of the <see cref=”PostCode”/> property.
        /// </summary>
        public string PostCode
        {
            get { return _postCode; }
            set
            {
                if (_postCode != value)
                {
                    _postCode = value;
                    OnPropertyChanged("PostCode");
                }
            }
        }

        #endregion

        #region IChangeTrackable Members

        public ChangeService ChangeService
        {
            get { return _changeService; }
        }

        #endregion
    }
}